﻿<UserControl x:Class="ClosePrograms.CloseProgramsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:vm="clr-namespace:ClosePrograms"
             mc:Ignorable="d" Height="220" Width="Auto" Margin="8,8,8,0" >
    <UserControl.Resources>
        <vm:CloseProgramsViewModel x:Key="closeProgramsViewModel"/>
    </UserControl.Resources>
    <Grid Height="Auto">
        <Grid.RowDefinitions>
            <RowDefinition Height="63" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid Grid.Row="0" Height="63">
            <CheckBox Name="checkBoxCloseThesePrograms" Content="Close these programs" Height="16" HorizontalAlignment="Left" 
                VerticalAlignment="Top" 
                IsChecked="{Binding Source={StaticResource closeProgramsViewModel}, Path=Model.CloseThesePrograms}"
                IsEnabled="{Binding Source={StaticResource closeProgramsViewModel}, Path=Model.GivingAPresentation}" />
            <CheckBox Name="checkBoxKillIfCannotClose" Content="Kill if cannot close" Height="16" HorizontalAlignment="Left" 
                VerticalAlignment="Top" Margin="138,0,0,0" 
                IsChecked="{Binding Source={StaticResource closeProgramsViewModel}, Path=Model.KillIfCannotClose}"
                IsEnabled="{Binding Source={StaticResource closeProgramsViewModel}, Path=Model.CloseThesePrograms}" />
            <CheckBox Name="checkBoxAskFirst" Content="Ask first" Height="16" HorizontalAlignment="Left" VerticalAlignment="Top"
                Margin="256,0,0,0" 
                IsChecked="{Binding Source={StaticResource closeProgramsViewModel}, Path=Model.AskFirst}"
                IsEnabled="{Binding Source={StaticResource closeProgramsViewModel}, Path=Model.CanAskFirst}" />
            <Button Name="buttonAddRunning" Content="Add running..."  Width="95" Height="23" HorizontalAlignment="Left" VerticalAlignment="Top"
                Margin="0,28,0,0"
                Command="{Binding Source={StaticResource closeProgramsViewModel}, Path=AddRunningProgram}" CommandParameter="{Binding ElementName=listBox}" />
            <Button Name="buttonAddFile" Content="Add from file..." Width="95" Height="23" HorizontalAlignment="Left" VerticalAlignment="Top"
                Margin="101,28,0,0" 
                Command="{Binding Source={StaticResource closeProgramsViewModel}, Path=AddProgramFromFile}" CommandParameter="{Binding ElementName=listBox}" />
            <Button Name="buttonRemove" Content="Remove" Width="75" Height="23" HorizontalAlignment="Left" VerticalAlignment="Top"
                Margin="202,28,0,0" 
                Command="{Binding Source={StaticResource closeProgramsViewModel}, Path=RemoveProgram}" 
                CommandParameter="{Binding ElementName=listBox}" />
        </Grid>
        <ListBox Grid.Row="1" Name="listBox" Width="Auto" Height="157" BorderThickness="0" SelectionMode="Extended"
            ItemsSource="{Binding Source={StaticResource closeProgramsViewModel}, Path=Model.Programs}"  Margin="0,0,0,0">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Column="0"
                            Text="{Binding FriendlyName}" />
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</UserControl>
